# 7-1 自除数【函数】
def sDn():
    def selfDivisor(num):
        for digit in str(num):
            if digit == '0' or num % int(digit) != 0:
                return False
        return True

    def find_selfDivisors(N):
        result = []
        for i in range(1, N+1):
            if selfDivisor(i):
                result.append(i)
        return result
    N = int(input())
    selfDivisors = find_selfDivisors(N)
    for num in selfDivisors:
        print(num, end=' ')
sDn()